ThisBuild / version := "0.1.0-SNAPSHOT"
ThisBuild / organization := "com.cw"
ThisBuild / scalaVersion := "2.12.19"

val flinkVersion = "1.17.1"
val hadoopVersion = "3.3.4"
val flinkCDCVersion = "2.4.0"
val jdbcConnectorVer = "3.1.0-1.17"
val fastjsonVersion = "1.2.83"
val hbaseVersion = "2.4.11"
val circeVersion = "0.14.10"

lazy val scalaReflect = Def.setting {
  "org.scala-lang" % "scala-reflect" % scalaVersion.value
}


lazy val sharedDependencies = Seq(
  "org.apache.flink" %% "flink-streaming-scala" % flinkVersion % "provided",
  "org.apache.flink" % "flink-clients" % flinkVersion % "provided",
  "org.apache.flink" % "flink-runtime-web" % flinkVersion % "provided",
  "org.apache.flink" % "flink-json" % flinkVersion % "provided",
  "org.apache.flink" % "flink-csv" % flinkVersion % "provided",
  "org.apache.hadoop" % "hadoop-client" % hadoopVersion % "provided",
  "org.slf4j" % "slf4j-api" % "1.7.25" % "provided",
  "org.slf4j" % "slf4j-log4j12" % "1.7.25" % "provided",
  "org.apache.logging.log4j" % "log4j-to-slf4j" % "2.14.0" % "provided",
  "org.apache.flink" %% "flink-table-api-scala-bridge" % flinkVersion % "provided",
  "org.apache.flink" % "flink-table-planner-loader" % flinkVersion % "provided",
  "org.apache.flink" % "flink-table-runtime" % flinkVersion % "provided",
  "org.apache.flink" % "flink-connector-files" % flinkVersion % "provided"
)

lazy val root = (project in file("."))
//  .aggregate(common, dim)


lazy val macroSub = (project in file("macroSub"))
  .settings(
    //    name := "realtime-macroSub",
    idePackagePrefix := Some("com.cw.realtime.macroSub"),
    libraryDependencies ++= Seq(scalaReflect.value)
  )


lazy val common = (project in file("realtime-common"))
  .settings(libraryDependencies ++= sharedDependencies)
  .settings(
    name := "realtime-common",
    libraryDependencies ++= Seq(
      "com.alibaba" % "fastjson" % fastjsonVersion,
      "org.apache.flink" % "flink-connector-kafka" % flinkVersion,
      "com.ververica" % "flink-connector-mysql-cdc" % flinkCDCVersion,
      "org.apache.hbase" % "hbase-client" % hbaseVersion,
      "org.apache.hadoop" % "hadoop-auth" % hadoopVersion % "provided" exclude("org.slf4j", "slf4j-reload4j"),
      "org.apache.flink" % "flink-connector-hbase-2.2" % flinkVersion,
      "org.apache.doris" % "flink-doris-connector-1.17" % "1.4.0",
      "commons-beanutils" % "commons-beanutils" % "1.9.4",
      "com.janeluo" % "ikanalyzer" % "2012_u6",
      "redis.clients" % "jedis" % "3.3.0",
      "io.lettuce" % "lettuce-core" % "6.2.4.RELEASE",
      "io.circe" %% "circe-core" % circeVersion,
      "io.circe" %% "circe-generic" % circeVersion,
      "io.circe" %% "circe-parser" % circeVersion,
      "io.circe" %% "circe-optics" % "0.14.1",
      "io.circe" %% "circe-generic-extras" % "0.14.4",
      "org.apache.flink" % "flink-connector-jdbc" % "3.2.0-1.19" % Test
    ),
    idePackagePrefix := Some("com.cw.realtime.common"),
    dependencyOverrides ++= Seq(
      "mysql" % "mysql-connector-java" % "8.0.31"
    )
  ).dependsOn(macroSub)


lazy val dwd_interaction_comment_info = (project in file("realtime-dwd/interaction-comment-info"))
  .settings(
    idePackagePrefix := Some("com.cw.realtime.dwd"),
    libraryDependencies ++= sharedDependencies
  )
  .dependsOn(common % "provided")

lazy val dwd_base_log = (project in file("realtime-dwd/base-log"))
  .settings(
    idePackagePrefix := Some("com.cw.realtime.dwd"),
    libraryDependencies ++= sharedDependencies
  )
  .dependsOn(common % "provided")

lazy val dwd_trade_cart_add = (project in file("realtime-dwd/trade-cart-add"))
  .settings(
    idePackagePrefix := Some("com.cw.realtime.dwd"),
    libraryDependencies ++= sharedDependencies
  )
  .dependsOn(common % "provided")


lazy val dwd_trade_order_detail = (project in file("realtime-dwd/trade-order-detail"))
  .settings(
    idePackagePrefix := Some("com.cw.realtime.dwd"),
    libraryDependencies ++= sharedDependencies
  )
  .dependsOn(common % "provided")


lazy val dwd_trade_order_pay_suc_detail = (project in file("realtime-dwd/dwd-trade-order-pay-suc-detail"))
  .settings(
    idePackagePrefix := Some("com.cw.realtime.dwd"),
    libraryDependencies ++= sharedDependencies
  ).dependsOn(common % "provided")


lazy val dwd_trade_order_cancel_detail = (project in file("realtime-dwd/trade-order-cancel-detail"))
  .settings(
    idePackagePrefix := Some("com.cw.realtime.dwd"),
    libraryDependencies ++= sharedDependencies
  ).dependsOn(common % "provided")


lazy val dwd_base_db = (project in file("realtime-dwd/base-db"))
  .settings(
    idePackagePrefix := Some("com.cw.realtime.dwd"),
    libraryDependencies ++= sharedDependencies
  ).dependsOn(common % "provided")


lazy val dim = (project in file("realtime-dim"))
  .settings(
    name := "realtime-dim",
    idePackagePrefix := Some("com.cw.realtime.dim"),
    libraryDependencies ++= sharedDependencies

  ).dependsOn(common % "provided")


lazy val dwsPrefix = "realtime-dws"

lazy val dws_keyword = (project in file(s"$dwsPrefix/traffic-keyword-page-view-window"))
  .settings(
    idePackagePrefix := Some("com.cw.realtime.dws"),
    libraryDependencies ++= sharedDependencies
  ).dependsOn(common % "provided")


lazy val dws_traffic_user_visit_page_view_window = (project in file(s"$dwsPrefix/traffic-user-visit-page-view-window"))
  .settings(
    idePackagePrefix := Some("com.cw.realtime.dws"),
    libraryDependencies ++= sharedDependencies,

  ).dependsOn(common % "provided")



lazy val dws_traffic_home_detail_page_view_window  = (project in file(s"$dwsPrefix/traffic-home-detail-page-view-window"))
  .settings(
    idePackagePrefix := Some("com.cw.realtime.dws"),
    libraryDependencies ++= sharedDependencies,
  ).dependsOn(common % "provided")


lazy val dws_user_user_login_window = (project in file(s"$dwsPrefix/user-user-login-window"))
  .settings(
    idePackagePrefix := Some("com.cw.realtime.dws"),
    libraryDependencies ++= sharedDependencies,
  ).dependsOn(common % "provided")


lazy val dws_user_user_register_window = (project in file(s"$dwsPrefix/user-user-register-window"))
  .settings(
    idePackagePrefix := Some("com.cw.realtime.dws"),
    libraryDependencies ++= sharedDependencies,
  ).dependsOn(common % "provided")

lazy val dws_trade_cart_add_uu_window = (project in file(s"$dwsPrefix/dws-trade-cart-add-uu-window"))
  .settings(
    idePackagePrefix := Some("com.cw.realtime.dws"),
    libraryDependencies ++= sharedDependencies,
  ).dependsOn(common % "provided")

lazy val dws_trade_sku_order_window = (project in file(s"$dwsPrefix/trade-sku-order-window"))
  .settings(
    idePackagePrefix := Some("com.cw.realtime.dws"),
    libraryDependencies ++= sharedDependencies,
  ).dependsOn(common % "provided")


lazy val dws_trade_province_order_window = (project in file(s"$dwsPrefix/trade-province-order-window"))
  .settings(
    idePackagePrefix := Some("com.cw.realtime.dws"),
    libraryDependencies ++= sharedDependencies,
  ).dependsOn(common % "provided")



